package com.taotao.springboot2.common.mybatis.plus.update.force;


import com.baomidou.mybatisplus.core.metadata.TableFieldInfo;
import com.baomidou.mybatisplus.core.metadata.TableInfo;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.util.Objects;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class TableInfoUtil {


    public static TableFieldInfo getTableFieldInfoByProperty(String property, TableInfo tableInfo){
        for(TableFieldInfo f:tableInfo.getFieldList()){
            if(Objects.equals(property,f.getProperty())){
                return f;
            }
        }

        return null;
    }

    public static TableFieldInfo getTableFieldInfoBycolumn(String column, TableInfo tableInfo){
        for(TableFieldInfo f:tableInfo.getFieldList()){
            if(Objects.equals(column,f.getColumn())){
                return f;
            }
        }

        return null;
    }
}
